const resource = {
    namespaced: true,
    state: {
        upload: {
            uploading: false,
            result: {
                success: false,
            },
            progress: {
                loaded: 111104,
                total: 111104,
                speed: 232435.15,
                percent: 1
            }
        }
    },
    // 逻辑处理,同步函数
    mutations: {
        uploadStart(state) {
            state.upload.uploading = true;
        },
        uploadEnd(state, payload) {
            state.upload.result = payload;
            state.upload.uploading = false;
        },
        uploadUpdate(state, payload) {
            state.upload.uploading = true;
            state.upload.progress = payload;
        }
    },
    // 逻辑处理,异步函数
    actions: {},
    getters: {
        getUploadState: state => {
            return state.upload.uploading
        },
        getUploadResult: state => {
            return state.upload.result;
        },
        getUploadProgress: state => {
            return state.upload.progress.percent
        }
    }
}

export default resource;